//
//  AiRoleBean.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/8.
//

import Foundation
import LeanCloud
import GRDB

//评论
class DiaryCommentBean : ICloudTable,IDbTable,Identifiable {
    static let databaseTableName = "DiaryComment"

    func getCloudTable() -> String {
        return "DiaryComment"
    }
    
    //leanCloud 排除字段
    func doCustomExcluded() -> [String? : Any?] {
        return doExcluded(subject: self, excluded: ["createTime","updateTime","modifySign","status"])
    }
    
    //db排除字段
    func doCustomDBExcluded()  -> [String? : Any?] {
        return doExcluded(subject: self, excluded: [""])
    }
    
    var objectId: String?
    var diaryId: String? = nil
    var userId: String? = nil
    var content: String? = nil
    var time: Int64 = 0
    var role: RoleBean? = nil
    var roleId: String? = nil//角色id

    var createTime: Int64 = 0//创建时间
    var updateTime: Int64 = 0//更新时间时间
    var modifySign: Bool = false//修改标识
    var status: Int = IStatusType.NORMAL.rawValue
    
    //json解析白名单
    private enum CodingKeys: String, CodingKey {
        case objectId
        case diaryId
        case userId
        case content
        case time
        case role
//        case createTime
//        case updateTime
//        case modifySign
//        case status
        }
}

extension DiaryCommentBean {
    // db数据库指定字段
    public func encode(to container: inout PersistenceContainer) {
        doDBExcluded(to: &container)
    }
}
